/*
 * ivi_config.h :
 *  IVI Compile-Time Configuration File
 *
 */

#ifndef IVI_CONFIG_H
#define IVI_CONFIG_H

#ifdef __KERNEL__

#include <linux/module.h>

// comment this line out if you don't want to track any debug information
#define IVI_DEBUG

// comment this line out if you don't want to track any debug information of tcp connection state
//#define IVI_DEBUG_TCP

// comment this line out if you don't want to track any debug information of port mapping
//#define IVI_DEBUG_MAP

#define IVI_HTABLE_SIZE		32
#define GOLDEN_RATIO_32		0x9e370001

// Generic hash function for a 32 bit value, see 'Introduction to Algorithms, 2nd Edition' Section 11.3.2
static inline int key32_hashfn(__be32 key)
{
	__be32 m = key * GOLDEN_RATIO_32;
	return ((m & 0xf8000000) >> 27);  // extract highest 5 bits as hash result
}

#ifndef NIP4
#define NIP4(addr) \
	((unsigned char *)&addr)[3], \
	((unsigned char *)&addr)[2], \
	((unsigned char *)&addr)[1], \
	((unsigned char *)&addr)[0]
#define NIP4_FMT "%u.%u.%u.%u"
#endif

#endif /* __KERNEL__ */

#endif /* IVI_CONFIG_H */
